//
//  HomeViewController.m
//  QuickCure
//
//  Created by haoge on 16/9/10.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "HomeViewController.h"
#import "WeatherView.h"
#import "AdsView.h"
#import "MainIconView.h"
#import "FocusDoctorModel.h"
#import "DoctorInfoViewController.h"
#import "DoctorInfoCollectionView.h"

@interface HomeViewController () <MainIconDelegate,WeatherViewDelegate>



@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
}

- (void)setupUI {
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.barTintColor = kThemeColor;
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    self.title = @"黑马快医";
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]};
    
    //天气
    WeatherView *wv = [[WeatherView alloc]initWithFrame:CGRectMake(0, 0, sWidth, 40) cityName:nil];
    wv.delegate = self;
    [self.view addSubview:wv];
    
    [wv makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.top.equalTo(self.view);
        make.height.equalTo(40);
    }];
    
    //Scroll View ads 广告 scroll view
    CGFloat adsHeight = 210;
    AdsView *adsview = [[AdsView alloc]initWithFrame:CGRectMake(0, 0, sWidth, adsHeight)];
    [self.view addSubview:adsview];
    
    [adsview makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.top.equalTo(wv.bottom);
        make.height.equalTo(adsHeight);
    }];

    //名医通 view
    CGFloat mcHeight = 200;
    MainIconView *mcView = [[MainIconView alloc]initWithFrame:CGRectMake(0, 0, sWidth, mcHeight)];
    mcView.delegate = self;
    [self.view addSubview:mcView];
    
    [mcView makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.top.equalTo(adsview.bottom);
        make.height.equalTo(mcHeight);
    }];

    //关注医生
    UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc]init];
    
    DoctorInfoCollectionView *diCollectionView = [[DoctorInfoCollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:flow];
    
    [self.view addSubview:diCollectionView];
    
    [diCollectionView makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.top.equalTo(mcView.bottom);
        make.bottom.equalTo(self.view);
    }];


    
    //通知中心
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center addObserver:self selector:@selector(jumpToDoctorInfoVC:) name:@"clickCell" object:nil];
    
    
}

-(void)jumpToDoctorInfoVC:(NSNotification *)notification{
    
    NSDictionary *dict = notification.userInfo;
    
    FocusDoctorModel *model = dict[@"data"];
    
    DoctorInfoViewController *doctorInfoVC = [[DoctorInfoViewController alloc]init];
    
    doctorInfoVC.model = model;
    
    [self.navigationController pushViewController:doctorInfoVC animated:YES];
    
}


-(void)jumpToVC:(UIViewController *)viewController {
    [self.navigationController pushViewController:viewController animated:YES];
}

-(void)jumpToProvinceTableView:(UIViewController *)viewController {
    [self.navigationController pushViewController:viewController animated:YES];
}

-(void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end














































